var product_order_ops={
	init:function(){
		this.eventBind();
	},
	eventBind:function(){
		//点击确认下单
		$(".do_order").click(function(){
			var address_id=$("input[name=address_id]:checked").val();//地址id
			console.log(address_id);
			var data=[];
			$(".order_list li").each(function(){
				var id=$(this).attr('data');
				var quantity=$(this).attr('data-quantity');
				data.push(id+'#'+quantity);

				if(data.length<1){
					common_ops.alert("请选择商品再提交");
					return;
				}
				
			});
			$.ajax({
					url:common_ops.buildMUrl('/product/order'),
					type:"POST",
					dataType:"json",
					data:{
						product_item:data,
						address_id:address_id,
					},
					success:function(res){
						callback=null;
						if(res.code!=200){
							common_ops.alert(res.msg);
							return;
						}
						callback=function(){
							var data=res.data;

							
							window.location.href=data.url;

						}
						common_ops.alert(res.msg,callback);
					}
				});
		});
	},
};
$(document).ready(function(){
	product_order_ops.init();
});